

clear 
set scheme lean2, permanent
global pm = char(177)
set more off

gl date = c(current_date)
if c(os) == "MacOSX" gl user "/Users/`c(username)'"
else if c(os) == "Windows" gl user "C:\Users\\`c(username)'"
else if c(os) == "Unix" gl user "/usr/`c(username)'"
di "$user
 
set graphics on  
  
global path_data_processed "\data\processed"
global path_output "\data\output"
 
clear all
set more off

cd "$path_data_processed"
use "experimentRNall.dta", clear

cd "$path_output"
 
duplicates drop rnid, force

keep rnid infl_bin1 infl_bin2 infl_bin3 infl_bin4 infl_bin5 infl_bin6 infl_bin7 infl_bin8 infl_bin9 infl_bin10



reshape long infl_bin, i(rnid) j(type) 

collapse (mean) infl_bin (sd) sd=infl_bin (count) n=infl_bin, by(type)



rename infl_bin action

gen standarderror = invttail(n-1,0.025)*(sd / sqrt(n))

gen id2=1 if type==1 
replace id2=2 if type==2  
replace id2=3 if type==3  
replace id2=4 if type==4  
replace id2=5 if type==5   
replace id2=6 if type==6 
replace id2=7 if type==7   
replace id2=8 if type==8   
replace id2=9 if type==9   
replace id2=10 if type==10   

    

 set scheme lean2


generate hiz_avg = action + 1*(standarderror)
generate lowz_avg = action - 1*(standarderror)
 
 
gen zero=0
 
   twoway    (rbar action zero id2)   (rcap hiz_avg lowz_avg id2 ),  legend(off) ///
 ylabel(0(5)30) ///
	xlabel( 1 "Deflation: 12% or higher " 2 "Deflation between 8% and 12%" 3 "Deflation between 4% and 8%" 4 "Deflation between 2% and 4%" 5 "Deflation between 0% and 2%" 6 "Inflation between 0% and 2%" 7 "Inflation between 2% and 4%" 8 "Inflation between 4% and 8%" 9 "Inflation between 8% and 12%" 10 "Inflation: 12% or higher", noticks labsize(*0.8) angle(45) ) ///	
	xtitle("Percent chance of different inflation/deflation rates over the next 12 months", size(*1)) ///
	ytitle(" ") ///	  
		name(inflation_distribution, replace)	
	   graph display inflation_distribution, xsize(20) ysize(10)
		graph export "inflation_distribution.eps", replace
		graph export "inflation_distribution.pdf", replace
		graph save "inflation_distribution.gph", replace



	
	   
	   
	   

